package com.zqx.flyweight.client;

import com.zqx.flyweight.factory.IgoChessmanFactory;
import com.zqx.flyweight.flyweight.IgoChessman;
import com.zqx.flyweight.outflyweight.Coordinates;
import lombok.extern.slf4j.Slf4j;

/**
 * description: 客户端测试
 * @author zqx
 * @date 2018/09/04
 */
@Slf4j
public class Client {

    public static void main(String[] args) {
        //获取享元工厂对象
        IgoChessmanFactory instance = IgoChessmanFactory.getInstance();

        //通过享元工厂获取3枚黑棋子
        IgoChessman black1 = IgoChessmanFactory.getIgoChessman("black");
        IgoChessman black2 = IgoChessmanFactory.getIgoChessman("black");
        IgoChessman black3 = IgoChessmanFactory.getIgoChessman("black");

        //通过享元工厂获取2枚白棋子
        IgoChessman white1 = IgoChessmanFactory.getIgoChessman("white");
        IgoChessman white2 = IgoChessmanFactory.getIgoChessman("white");
        log.info("【两颗白棋子是否相同】,{}",white1==white2);

        //显示棋子
        black1.display(new Coordinates(1,2));
        black2.display(new Coordinates(3,4));
        black3.display(new Coordinates(1,3));
        white1.display(new Coordinates(2,5));
        white2.display(new Coordinates(2,3));


    }
}
